#include <iostream>
using namespace std;
#include <algorithm>

int process(int rest , int K , int M)
{
  if (rest <= 0)
  {
    return pow(static_cast<double>(M + 1) , K);
  }

  if (K == 0)
  {
    return rest <= 0 ? 1 : 0;
  }

  int ways = 0;
  for (int i = 0; i <= M; i++)
  {
    ways += process(rest - i , K - 1 , M);
  }

  return ways;
}

int dp_process( int N , int K , int M)
{
  vector<vector<int>> dp(K + 1 , vector<int>(N + 1 , 0));

  for (int i = 0; i <= K; i++)
  {
    dp[i][0] = pow(static_cast<double>(M+1) ,static_cast<double>(K));
  }



  for (int times = 1; times <= K; times++)
  {
    for(int hp = 1; hp <= N; hp++)
    {
       int ways = 0;
       for (int i = 0; i<= M; i++)
       {
         if (hp - i >= 0)
         {
           ways += dp[times - 1][hp - i];
         }
         else 
         {
           ways += dp[times-1][0];
         }
       }
       dp[times][hp] = ways;
    }
  }

  return dp[K][M];
}





int main()
{
  return 0;
}
